#ifndef WF_DRAWSPLINE_H
#define WF_DRAWSPLINE_H

#include "pf_previewactioninterface.h"
#include "pf_spline.h"
#include "gui_export.h"

/**
 * This action class can handle user events to draw splines.
 *
 */
class GUI_EXPORT WF_DrawSpline : public PF_PreviewActionInterface {
	Q_OBJECT
public:
    /**
     * Action States.
     */
    enum Status {
        SetStartpoint,   /**< Setting the startpoint.  */
        SetNextPoint      /**< Setting the next point. */
    };

public:
    WF_DrawSpline(PF_Container& container,
                      PF_GraphicView& graphicView);
    virtual ~WF_DrawSpline();

	virtual LX_Define::ActionType rtti() {
		return LX_Define::ActionDrawSpline;
	}

	static QAction* createGUIAction(LX_Define::ActionType /*type*/, QObject* /*parent*/);
	
    void reset();

    virtual void init(int status=0);
    virtual void trigger();
	
    virtual void mouseMoveEvent(QMouseEvent* e);
    virtual void mouseReleaseEvent(QMouseEvent* e);
	
	virtual void coordinateEvent(PF_CoordinateEvent* e);
    virtual void commandEvent(PF_CommandEvent* e);
        virtual QStringList getAvailableCommands();
	
	virtual void showOptions();
	virtual void hideOptions();
	
    virtual void updateMouseButtonHints();
    virtual void updateMouseCursor();
    virtual void updateToolBar();

	//void close();
	void undo();
	void setDegree(int deg);
	int getDegree();
	void setClosed(bool c);
	bool isClosed();

protected:
    /**
     * Spline data defined so far.
     */
    PF_SplineAttribute data;
	
    /**
     * Polyline entity we're working on.
     */
    PF_Spline* spline;
	
    /**
     * last point.
     */
    //PF_Vector point;

	/**
	 * Start point of the series of nodes. Used for close function.
	 */
	//PF_Vector start;

	/**
	 * Point history (for undo)
	 */
        QList<PF_Vector> history;
	
	/**
	 * Bulge history (for undo)
	 */
        //QList<double> bHistory;
};

#endif
